/**
 * 屏幕
 */
if ('function' != typeof LBUtility) {

    throw   'Little Bee core lib not import';
}

/**
 * 注册事件名
 */
LBUtility.getInstance().registSelector('lib/core/Render/LBRender.js');
LBUtility.getInstance().registSelector('lib/core/Render/LBRenderImage.js');

var	Screen	= function (options) {

	this._id	=  ++ Screen._IDSeed;
	this.initailize(options);
}
 
Screen._IDSeed	= 0;

Screen.prototype.getRealWidth	= function () {

	return	this._width * this._scale;
}

Screen.prototype.getRealHeight	= function () {

	return	this._height * this._scale;
}

Screen.prototype.initailize	= function (options) {
	
	this._width		= options.width;
	this._height	= options.height;
	this._scale		= options.scale;
	this.buildCanvas(options.holder);
}

Screen.prototype.buildCanvas	= function (HTMLElementForReplace) {

	this._canvasElement			= document.createElement('canvas');
	this._canvasElement.width	= this.getRealWidth();
	this._canvasElement.height	= this.getRealHeight();
	HTMLElementForReplace.parentNode.replaceChild(this._canvasElement, HTMLElementForReplace);
	this._render				= new LBRender();
	this._context				= this._canvasElement.getContext('2d');
	this._render.setContext(this._context);
}

Screen.prototype.getCanvasElement	= function () {
	
	return	this._canvasElement;
}

Screen.prototype.getRender	= function () {
	
	return	this._render;
}

Screen.prototype.clear	= function () {
	
	this._context.clearRect(0, 0, this.getRealWidth(), this.getRealHeight());
}
